package com.six.firstpage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.six.core.entity.BottomArticle;
import com.six.firstpage.service.BottomArticleService;
import com.six.firstpage.vo.SearchVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import kotlin.PublishedApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author:zzh
 * @create: 2023-02-27 17:03
 * @Description:
 */
@Api(value = "firstpage/bottomArticle", tags = {"底部链接后端接口"})
@RestController
@RequestMapping("firstpage/bottomArticle")
public class BottomArticleController {
    @Autowired
    private BottomArticleService bottomArticleService;

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SearchVo", name = "searchVo", value = "", required = true),
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "current", value = "", required = true),
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "pageSize", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("getBottomArticleByTitle/{current}/{pageSize}")
    public Page<BottomArticle> getBottomArticleByTitle(@RequestBody SearchVo searchVo, @PathVariable  Integer current, @PathVariable Integer pageSize){

      return bottomArticleService.getBottomArticleByTitle(searchVo.getTitle(), searchVo.getStatus() , current, pageSize);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "BottomArticle", name = "bottomArticle", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("addBottomArticleByTitle")
    public Integer addBottomArticle(@RequestBody BottomArticle bottomArticle){
        return bottomArticleService.addBottomArticle(bottomArticle);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "BottomArticle", name = "bottomArticle", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "PUT")
    @PutMapping("updateBottomArticle")
    public Integer updateBottomArticle(@RequestBody BottomArticle bottomArticle){
        return bottomArticleService.updateBottomArticle(bottomArticle);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "id", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @GetMapping("delBottomArticle/{id}")
    public Integer delBottomArticle(@PathVariable String id){
        return bottomArticleService.delBottomArticle(id);
    }

}
